import Vue from 'vue'
import Router from 'vue-router'
import more from '../components/more/more'
import sjDescription from '../components/sjDescription/sjDescription'
import refund from '../components/studentCardSearch/refund/refund'
Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/more',
      name: 'more',
      component: more,
      meta: {
        title: '更多',
        page_id: 'A0033',
        page_name: '更多'
      }
    },
    {
      path: '/sjDescription',
      name: 'sjDescription',
      component: sjDescription,
      meta: {
        title: '市郊铁路卡',
        page_id: 'A0041',
        page_name: '市郊铁路卡'
      }
    },
    {
      path: '/',
      redirect: '/more'
    },
    // 学生卡查询
    {
      path: '/studentCardSearch',
      name: 'refund',
      meta: {
        title: '学生卡查询',
        page_name: '学生卡查询',
        page_id: 'A0042'
      },
      component: refund,
    },
    // 卡券
    {
      path: '/cardBag',
      component: () => import('@/components/cardTicket/cardBag/cardBag'),
      name: "cardBag",
      meta: {
        title: "卡券",
        page_id:'A0034',
        page_name:'卡劵'
      }
    }, {
      path: '/failure',
      component: () => import('@/components/cardTicket/failure'),
      name: "failure",
      meta: {
        title: "失效卡",
        page_id:'A0222',
        page_name:'查看失效卡劵'
      }
    },
    // 企业员工卡
    {
      path: '/staffCard',
      name: 'Inindex',
      component: () =>
        import('@/components/staffCard/index/index'),
      meta: {
        title: '企业员工卡',
        page_name: '企业员工卡',
        page_id: 'A0445'
      }
    }, {
      path: '/replayCard',
      name: 'replayCard',
      component: () =>
        import('@/components/staffCard/ReplayCard/index'),
      meta: {
        title: '企业员工卡',
        page_name: '企业员工卡换卡',
        page_id: 'A0235'
      }
    }, {
      path: '/sendSms',
      name: 'sendSms',
      component: () =>
        import('@/components/staffCard/sendSms/index'),
      meta: {
        title: '企业员工卡',
        page_name: '企业员工卡换卡',
        page_id: 'A0236'
      }
    }, {
      path: '/results',
      name: 'results',
      component: () =>
        import('@/components/staffCard/results/index'),
      meta: {
        title: '企业员工卡',
        page_name: '企业员工卡结果页',
        page_id: 'A0446'
      }
    }, {
      path: '/Report',
      name: 'Report',
      component: () =>
        import('@/components/staffCard/Report/index'),
      meta: {
        title: '企业员工卡',
        page_name: '账户挂失',
        page_id: 'A0237'
      }
    },
    //坏卡退资
    {
      path: '/queryOrderNum',
      name: 'queryOrderNum',
      component: () =>
        import('@/components/badCardRefund/queryOrderNum'),
      meta: {
        title: '坏卡退资',
        page_name:'坏卡退资',
        page_id:'A0448'
      }
    },
    {
      path: '/refundAmtChannel',
      name: 'refundAmtChannel',
      component: () =>
        import('@/components/badCardRefund/refundAmtChannel'),
      meta: {
        title: '坏卡退资',
        page_name:'坏卡退资_选择退资渠道',
        page_id:'A0449'
      }
    },
    {
      path: '/resultPage',
      name: 'resultPage',
      component: () =>
        import('@/components/badCardRefund/resultPage'),
      meta: {
        title: '退卡结果',
        page_name:'坏卡退资_退卡结果',
        page_id:'A0450'
      }
    }
  ],
  // mode:'history'
})
router.beforeEach((to, from, next) => {
  try {
    Vue.prototype.$setPage.registerPage({
      page_name: to.meta.page_name,
      page_id: to.meta.page_id
    })
  } catch (error) {
    console.log('路由神策埋点失败---->');
  }
  // 在这里可以执行一些逻辑，例如身份验证、权限检查等
  if (to.meta.title) {
    document.title = to.meta.title
  }
  // 继续导航
  next();
})
export default router
